<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;

class SystemInputDTO extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        return [
            'name' => 'required|between:1,18',
            'role_id' => 'required|integer',
            'real_name' => 'required|between:1,15',
            'password' => 'confirmed|between:5,15',
        ];
    }

    public function messages()
    {
        return [
            'name.required' => '账号不能为空',
            'name.between' => '账号格式不合法',
            'role_id.required' => '请选择角色',
            'role_id.between' => '角色不合法',
            'real_name.required' => '真实姓名不能为空',
            'real_name.between' => '真实姓名不超过15个字符',
            'password.required' => '请填写密码',
            'password.between' => '密码长度不符合规则',
            'password.confirmed' => '两次输入密码不一致',
        ];
    }
}
